home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Networking / SNMP / SNMP Development / MacSNMP Developer 1.0.2 / Sample Agent / Sources / SampleAgent.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  3.2 KB  |  116 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SampleSNMPAgent.h
  3.  
  4.     Contains:    Declaration for SampleSNMPAgent
  5.  
  6.     Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #ifndef __SAMPLESNMPAGENT__
  11. #define __SAMPLESNMPAGENT__    
  12.  
  13. #ifndef __SNMP__
  14. #include "SNMP.h"
  15. #endif
  16.  
  17. #ifndef __TSNMP__
  18. #include "TSNMP.h"
  19. #endif
  20.  
  21. /*
  22.     Structures representing groups and variables in the variable description resource.
  23.     This resource contains all the information about the variables and groups that
  24.     an agent supports.  The resource also contains variable description strings
  25.     used by the MacSNMP setup application. See the file SNMPTypes.r
  26.     Below are structures for the resource header, groups, indirect variables,
  27.     and direct variables.  For more information on indirect and direct variables,
  28.     see the main program code SampleAgent.cp
  29. */
  30.  
  31. // type and id of the variable description resource.
  32. #define     kVarRsrcType    'vard'        // variable description resource type
  33. #define        kVarRsrcID        128            // variable description resource id
  34.  
  35. #define     kOurVersion     1            // version of this agent used for registration
  36.  
  37.  
  38. // group resource structure
  39.  
  40. typedef struct {
  41.     unsigned short        strIndex;            // group string index
  42.     ObjectID            objID;                // group object id
  43. }
  44.     GroupRsrc;
  45.     
  46. typedef GroupRsrc    *GroupRsrcPtr;
  47.  
  48. // structure for the resource header
  49.  
  50. typedef struct {
  51.     short                namesResID;            // name strings resource id
  52.     short                descResID;            // description strings resource id
  53.     short                agentStrIndex;        // agent string index
  54.     short                groupCount;            // first group resource
  55. }
  56.     VarDescRsrc;
  57.     
  58. typedef VarDescRsrc        *VarDescRsrcPtr;
  59.  
  60.  
  61. // variable resourc structure
  62.  
  63. typedef struct {
  64.     unsigned short        strIndex;            // string index
  65.     ASNTagType            type;                // asn type
  66.     short                access;                // access
  67.     short                dataSize;            // size of variable
  68.     short                ptrIndex;            // index to array holding ptr to var or function
  69.     long                varType;            // type of var - 0 = indirect, 1 = direct
  70.     ObjectID            objID;                // object id
  71. }
  72.     VarRsrc;
  73.     
  74. typedef VarRsrc        *VarRsrcPtr;
  75.  
  76. // typedefs for get and set callback functions
  77.  
  78. typedef OSErr
  79.   GetVarProc (
  80.     Boolean     next,        // is it get or the powerful get-next?
  81.     ObjectIDPtr id,         // unique identifier of a variable
  82.     Ptr         bufPtr,     // where to return the variable's value
  83.     Size         bufSize,     // size of buffer to fill
  84.     Size         *bufUsed);    // size of value returned
  85.  
  86. typedef GetVarProc *GetVarProcPtr;
  87.  
  88. typedef OSErr 
  89.   SetVarProc (
  90.     ObjectIDPtr id,         // unique identifier of a variable
  91.     Ptr         bufPtr,     // value for the variable
  92.     Size         bufSize,    // size of the value
  93.     SetStage    action );    // ensuring simultaneous sets
  94.  
  95. typedef SetVarProc *SetVarProcPtr;
  96.  
  97. /*************************************************************************
  98.     TSampleSNMPagent Class
  99. *************************************************************************/
  100.  
  101. #define kTSampleSNMPAgentID     "snmp:agt$TSampleSNMPAgent"
  102.  
  103. class TSampleSNMPAgent : public TSNMPAgent {
  104.  
  105.     public:
  106.         TSampleSNMPAgent();
  107.         virtual ~TSampleSNMPAgent();
  108.         virtual Boolean    IsValid() const;        // returns valid or not valid state of
  109.                                                 // agent - set by contructor
  110.     private:
  111.         Boolean                fValid;                // agent valid flag - set in contructor
  112.         Boolean                fRegistered;            // agent registered flag - set in constructor
  113. };
  114.  
  115. #endif __SAMPLESNMPAGENT__
  116.